/**
 * SportType.java
 * Version: 1.0
 * Created in 06/08/2013
 * Created by: Gerson Groth
 * 
 * Copyright
 */
package activities.base.utils;

import java.util.ArrayList;

/**
 * The Enum SportType.
 * 
 * @author Gerson Groth
 */
public enum SportType {

	/** The all. */
	ALL(
			"Any Activity Type",
			"all"),

	/** The running. */
	RUNNING(
			"Running",
			"running"),

	/** The street running. */
	STREET_RUNNING(
			"Street Running",
			"street_running",
			RUNNING),

	/** The track running. */
	TRACK_RUNNING(
			"Track Running",
			"track_running",
			RUNNING),

	/** The trail running. */
	TRAIL_RUNNING(
			"Trail Running",
			"trail_running",
			RUNNING),

	/** The treadmill running. */
	TREADMILL_RUNNING(
			"Treadmill Running",
			"treadmill_running",
			RUNNING),

	/** The cycling. */
	CYCLING(
			"Cycling",
			"cycling"),

	/** The cyclocros. */
	CYCLOCROS(
			"Cyclocross",
			"cyclocross",
			CYCLING),

	/** The downhill biking. */
	DOWNHILL_BIKING(
			"Downhill Biking",
			"downhill_biking",
			CYCLING),

	/** The indoor cycling. */
	INDOOR_CYCLING(
			"Indoor Cycling",
			"indoor_cycling",
			CYCLING),

	/** The mountain biking. */
	MOUNTAIN_BIKING(
			"Mountain Biking",
			"mountain_biking",
			CYCLING),

	/** The recumbent cycling. */
	RECUMBENT_CYCLING(
			"Recumbent Cycling",
			"recumbent_cycling",
			CYCLING),

	/** The road cycling. */
	ROAD_CYCLING(
			"Road Cycling",
			"road_biking",
			CYCLING),

	/** The track cycling. */
	TRACK_CYCLING(
			"Track Cycling",
			"track_cycling",
			CYCLING),

	/** The fitness equipment. */
	FITNESS_EQUIPMENT(
			"Fitness Equipment",
			"fitness_equipment"),

	/** The elliptical. */
	ELLIPTICAL(
			"Elliptical",
			"elliptical",
			FITNESS_EQUIPMENT),

	/** The indoor cardio. */
	INDOOR_CARDIO(
			"Indoor Cardio",
			"indoor_cardio",
			FITNESS_EQUIPMENT),

	/** The indoor rowing. */
	INDOOR_ROWING(
			"Indoor Rowing",
			"indoor_rowing",
			FITNESS_EQUIPMENT),

	/** The stair climbing. */
	STAIR_CLIMBING(
			"Stair Climbing",
			"stair_climbing",
			FITNESS_EQUIPMENT),

	/** The strength training. */
	STRENGTH_TRAINING(
			"Strength Training",
			"strength_training",
			FITNESS_EQUIPMENT),

	/** The hiking. */
	HIKING(
			"Hiking",
			"hiking"),

	/** The swimming. */
	SWIMMING(
			"Swimming",
			"swimming"),

	/** The lap swimming. */
	LAP_SWIMMING(
			"Lap Swimming",
			"lap_swimming",
			SWIMMING),

	/** The open water swimming. */
	OPEN_WATER_SWIMMING(
			"Open Water Swimming",
			"open_water_swimming",
			SWIMMING),

	/** The walking. */
	WALKING(
			"Walking",
			"walking"),

	/** The casual walking. */
	CASUAL_WALKING(
			"Casual Walking",
			"casual_walking",
			WALKING),

	/** The speed walking. */
	SPEED_WALKING(
			"Speed Walking",
			"speed_walking",
			WALKING),

	/** The transition. */
	TRANSITION(
			"Transition",
			"transition"),

	/** The swim bike transition. */
	SWIM_BIKE_TRANSITION(
			"Swim to Bike Transition",
			"swimToBikeTransition",
			TRANSITION),

	/** The bike run transition. */
	BIKE_RUN_TRANSITION(
			"Bike to Run Transition",
			"bikeToRunTransition",
			TRANSITION),

	/** The run bike transition. */
	RUN_BIKE_TRANSITION(
			"Run to Bike Transition",
			"runToBikeTransition",
			TRANSITION),

	/** The motorcycling. */
	MOTORCYCLING(
			"Motorcycling",
			"motorcycling"),

	/** The other. */
	OTHER(
			"Other",
			"other"),

	/** The backcountry skiing snowboarding. */
	BACKCOUNTRY_SKIING_SNOWBOARDING(
			"Backcountry Skiing/Snowboarding",
			"backcountry_skiing_snowboarding",
			OTHER),

	/** The boating. */
	BOATING(
			"Boating",
			"boating",
			OTHER),

	/** The cross country skiing. */
	CROSS_COUNTRY_SKIING(
			"Cross Country Skiing",
			"cross_country_skiing",
			OTHER),

	/** The driving. */
	DRIVING(
			"Driving",
			"driving_general",
			OTHER),

	/** The flying. */
	FLYING(
			"Flying",
			"flying",
			OTHER),

	/** The golf. */
	GOLF(
			"Golf",
			"golf",
			OTHER),

	/** The horseback riding. */
	HORSEBACK_RIDING(
			"Horseback Riding",
			"horseback_riding",
			OTHER),

	/** The inline skating. */
	INLINE_SKATING(
			"Inline Skating",
			"inline_skating",
			OTHER),

	/** The mountaineering. */
	MOUNTAINEERING(
			"Mountaineering",
			"mountaineering",
			OTHER),

	/** The paddling. */
	PADDLING(
			"Paddling",
			"paddling",
			OTHER),

	/** The resort skiing snowboarding. */
	RESORT_SKIING_SNOWBOARDING(
			"Resort Skiing/Snowboarding",
			"resort_skiing_snowboarding",
			OTHER),

	/** The rowing. */
	ROWING(
			"Rowing",
			"rowing",
			OTHER),

	/** The sailing. */
	SAILING(
			"Sailing",
			"sailing",
			OTHER),

	/** The skate skiing. */
	SKATE_SKIING(
			"Skate Skiing",
			"skate_skiing",
			OTHER),

	/** The skating. */
	SKATING(
			"Skating",
			"skating",
			OTHER),

	/** The snowmobiling. */
	SNOWMOBILING(
			"Snowmobiling",
			"snowmobiling",
			OTHER),

	/** The snowshoeing. */
	SNOWSHOEING(
			"Snowshoeing",
			"snow_shoe",
			OTHER),

	/** The stand up paddleboarding. */
	STAND_UP_PADDLEBOARDING(
			"Stand Up Paddleboarding",
			"stand_up_paddleboarding",
			OTHER),

	/** The whitewater kayaking rafting. */
	WHITEWATER_KAYAKING_RAFTING(
			"Whitewater Kayaking/Rafting",
			"whitewater_rafting_kayaking",
			OTHER),

	/** The wind kite surfing. */
	WIND_KITE_SURFING(
			"Wind/Kite Surfing",
			"wind_kite_surfing",
			OTHER);

	/** The sport. */
	private String sport;

	/** The value. */
	private String value;

	/** The children. */
	private ArrayList<SportType> children = new ArrayList<SportType>();

	/** The parent. */
	private SportType parent;

	/**
	 * Instantiates a new sport type.
	 * 
	 * @param sport
	 *            the sport
	 * @param value
	 *            the value
	 */
	SportType(String sport, String value) {
		this.sport = sport;
		this.value = value;
	}

	/**
	 * Instantiates a new sport type.
	 * 
	 * @param sport
	 *            the sport
	 * @param value
	 *            the value
	 * @param parent
	 *            the parent
	 */
	SportType(String sport, String value, SportType parent) {
		this.sport = sport;
		this.value = value;
		this.parent = parent;
		parent.addChild(this);
	}

	/**
	 * Adds the child.
	 * 
	 * @param sportType
	 *            the sport type
	 */
	private void addChild(SportType sportType) {
		children.add(sportType);
	}

	/**
	 * Gets the sport.
	 * 
	 * @return the sport
	 */
	public String getSport() {
		return sport;
	}

	/**
	 * Gets the children.
	 * 
	 * @return the children
	 */
	public ArrayList<SportType> getChildren() {
		return children;
	}

	/**
	 * Gets the value.
	 * 
	 * @return the value
	 */
	public String getValue() {
		return value;
	}

	/**
	 * Gets the parent.
	 * 
	 * @return the parent
	 */
	public SportType getParent() {
		return parent;
	}

	/**
	 * Gets the child.
	 * 
	 * @param index
	 *            the index
	 * @return the child
	 */
	public SportType getChild(int index) {
		return this.children.get(index);
	}

	/**
	 * Size.
	 * 
	 * @return The number of children
	 */
	public int size() {
		return this.children.size();
	}

	/**
	 * Gets the sport.
	 * 
	 * @param name
	 *            the name
	 * @return the sport
	 */
	public static SportType getSport(String name) {
		for (SportType sport : SportType.values()) {
			if (sport.getSport().equals(name))
				return sport;
		}
		return null;
	}

}
